<template>
  <div class="report-request-position-dialog">
    <el-dialog title="反馈缺少职业" :visible.sync="dialogVisible" width="400px" top="15%" :before-close="dialogBeforeClose"
      append-to-body>
      <el-form :model="form" :rules="rules" label-position="left" ref="form">
        <el-form-item label="职业名称：" label-width="100px" prop="positionName">
          <el-input v-model="form.positionName" size="small"  :maxlength="20" placeholder="请输入职业名称"></el-input>
        </el-form-item>
        <el-form-item label="行业名称：" label-width="100px" prop="industryName">
          <el-input v-model="form.industryName" size="small" :maxlength="20" placeholder="请输入行业名称"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="dialogVisible = false" size="small">取 消</el-button>
        <el-button type="primary" @click="handleConfirm" :loading="loading" size="small">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { feedbackPosition } from "@/api/position";
export default {
  name: "reportRequestPositionDialog",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      loading: false,
      form: {
        positionName: "",
        industryName: "",
      },
      rules: {
        positionName: [
          {
            required: true,
            message: "请输入职业名称",
            trigger: "blur",
          },
        ],
        industryName: [
          {
            required: false,
            message: "请输入行业名称",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    handleConfirm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true;
          const params = {
            personId: localStorage.getItem("personId")||"",
            title: this.form.positionName,
            industryName: this.form.industryName,
          };
          feedbackPosition(params)
            .then((res) => {
              if (res.code == 200) {
                this.$message.success("提交成功");
                this.$emit("update:dialogVisible", false);
              }
            })
            .catch((e) => {
              this.$message.warning("服务器开小差啦~请重试");
            })
            .finally(() => {
              this.loading = false;
            });
        }
      });
    },
    dialogBeforeClose() {
      this.$emit("update:dialogVisible", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.report-request-position-dialog {
  z-index: 20;
}
::v-deep .el-dialog {
  // height: 323px;
  border-radius: 12px;
  background-image: url("../../../assets/home/questionBack.png");
  background-repeat: no-repeat;
  background-size: 100% auto;
  .el-dialog__header {
    padding: 32px 36px 0 36px;
    .el-dialog__title {
      font-size: 20px;
      font-family: PingFang-SC-Bold, PingFang-SC;
      font-weight: bold;
      color: #222222;
      line-height: 28px;
    }
  }
  .el-dialog__body {
    padding: 13px 36px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
    .erweimaBox {
      width: 100%;
      padding: 26px 0 18px 0;
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 133px;
        height: 133px;
        margin: 0 44px;
      }
    }
  }
}
::v-deep .el-form-item:last-of-type {
  margin-bottom: 0px;
}
</style>